package generic.genetic.gene;

import generic.utils.PE_Utils;

public class DecimalGene extends Gene<Integer,Integer>{

	public DecimalGene(int i) {
		length = 1;
		genotype = new Integer[length];
		genotype[0] = i;
	}

	public DecimalGene(DecimalGene g) {
		this.length = g.getLength();
		genotype = new Integer[length];
		for (int i=0;i<length;i++) genotype[i] = new Integer(g.getGenotype(i));
	}

	@Override
	public DecimalGene getCopy() {
		return new DecimalGene(this);
	}

	@Override
	public Integer phenotype() {
		return genotype[0];
	}

	@Override
	public Integer randomGeneTypeValue() { return phenotype(); }

	
	@Override
	public String toString() {
		String s = "";
		for (Integer i : genotype) s += i+" ";
		s += ""; 
		return s;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (null == obj) return false;
		if (this == obj) return true;
		if (!(obj instanceof Gene)) return false;
		DecimalGene g = (DecimalGene) obj;
		if (this.length != g.length) return false;
		boolean eq = true;
		eq = genotype[0] == g.getGenotype(0);
		return eq;
	}
}
